
import java.util.Scanner;

/**
 * @author xizizzz
 * @description: TODO
 * @date 2021-9-8上午 09:13
 */
public class Test2 {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- > 0) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int[][] arr = new int[n][m];
            int index = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    arr[i][j] = ++index;
                }
            }
            int sum = (n * m * (1 + n * m)) / 2;
            int res = 0;
            String res1 = "V";
            int chazhi = Integer.MAX_VALUE;
            //V
            if (m > 1) {
                for (int i = 0; i < m; i++) {
                    int sum1 = 0;
                    for (int j = 0; j < n; j++) {
                        sum1 += arr[j][i];
                    }
                    if ((sum - sum1) < chazhi) {
                        res1 = "V";
                        res = i + 1;
                    }
                }
            }
            //H
            if (n > 1) {
                for (int i = 0; i < n; i++) {
                    int sum1 = 0;
                    for (int j = 0; j < m; j++) {
                        sum1 += arr[i][j];
                    }
                    if ((sum - sum1) < chazhi) {
                        res1 = "H";
                        res = i + 1;
                    }
                }
            }

            System.out.println(res1 + " " + (res));
        }
    }
}
